class MBtn extends egret.Sprite{
	public constructor(bgurl,x,y,w,h) {
		super();
		this._bgUrl = bgurl;
		// 设置位置
		this.x = x; 
		this.y = y;
		this._width = w;
		this._height = h;
		this.init(w,h);
	}
	// 传入的图片url
	private _bgUrl: string;
	// 背景图片
	public _bg: egret.Bitmap;
	// 宽高
	public _width: number;
	public _height: number;
	// 字体文本
	public btnText: egret.TextField;
	private init(w,h) {
		this._bg =new egret.Bitmap(RES.getRes(this._bgUrl));
		// 设置九宫格 
		var rect: egret.Rectangle = new egret.Rectangle(10,10,180,40);
		this._bg.scale9Grid = rect;
		this._bg.width = this._width;
		this._bg.height = this._height;
		this.addChild(this._bg);
		// 设置文本居中显示
		this.btnText = new egret.TextField();
		this.addChild(this.btnText);
		this.btnText.width = w;
		this.btnText.height = h;
		// 设置文本居中方式
		this.btnText.textAlign = egret.HorizontalAlign.CENTER;
		this.btnText.verticalAlign = egret.VerticalAlign.MIDDLE;
	}

	get width(): number{
		return this._bg.width;
	}
	set width(newWidth: number){
		this._bg.width = newWidth;
	}

}